<template>
	<view class="app">
		<view v-if="isShow" @click="show" class="mask" @touchmove.stop.prevent="()=>{}" catchtouchmove="true"></view>
		<view v-if="isShow" class="re">
			<view class="bacimg center">
				<image class="img-a" :src="inviteData.img"></image>
			</view>
			<view class="codeimg center">
				<image class="img-b" :src="inviteData.QR_Code"></image>
			</view>

			<view class="bttc center">
				<view class="bcbutton center" @click="bye">
					<text>确认保存</text>
				</view>
			</view>
		</view>

	</view>

	</view>
	</view>
	</view>
</template>

<script>
	export default {

		props: {
			inviteData: Object // 分享的数据
		},
		data() {
			return {
				reward: '',
				QR_Code: '',
				img: '',
				quantity: '',
				isShow: false, //默认不显示
			}
		},
		onLoad() {

		},
		methods: {
			// 显示隐藏评论窗口
			show() {
				this.isShow = !this.isShow
			},
			bye() {
				var that = this
				uni.getSetting({
					success(res) {
						if (!res.authSetting['scope.writePhotosAlbum']) {
							console.log(111)
							uni.showModal({
								title: '您还未授权相册权限',
								content: '点击确认授权',
								success(res) {
									if (res.confirm == true) {
										wx.authorize({
											scope: 'scope.writePhotosAlbum',
										})
									} else {
										uni.navigateTo({
											url: '../index/index'
										})
									}
								}
							})
						} else {
							console.log(666)
							uni.canvasToTempFilePath({
								x: 0,
								y: 0,
								width: that.windowWidth * 1.22, // 截取的画布的宽
								height: that.windowHeight * 1.22, // 截取的画布的高
								destWidth: that.windowWidth * 1.22 * 3, // 保存成的画布宽度
								destHeight: that.windowHeight * 1.22 * 3, // 保存成的画布高度
								fileType: 'jpg', // 保存成的文件类型
								quality: 1, // 图片质量
								canvasId: 'myCanvas',
								success(res) {
									console.log(res.tempFilePath)

									// 2-保存图片至相册
									uni.saveImageToPhotosAlbum({ // 存成图片至手机
										filePath: res.tempFilePath,
										success(res2) {
											uni.showToast({
												title: '图片保存成功',
												duration: 2000
											})
										},
										fail(res3) {
											uni.showToast({
												title: '保存失败，稍后再试',
												duration: 2000,
												icon: 'none'
											})
										}
									})
								},
								fail() {
									uni.showToast({
										title: '保存失败，稍后再试',
										duration: 2000,
										icon: 'none'
									})
								}
							})
						}
					},
					fail() {
						uni.showToast({
							title: '保存失败，稍后再试',
							duration: 2000,
							icon: 'none'
						})

					}
				})
			}

		}

	}
</script>

<style lang="scss">
	.app {
		.re {
			z-index: 100;
			position: fixed;
			left: 0rpx;
			right: 0rpx;
			bottom: 50rpx;
			top: 50rpx;

			.img-a {
				// position: absolute;
				top: 50rpx;
				height: 1300rpx;
				width: 650rpx;
				clip-path: inset(0rpx 0rpx 420rpx 0rpx);
				// clip: rect(0rpx,0rpx,0rpx,0rpx);
			}

			.img-b {
				z-index: 20;
				position: absolute;
				height: 300rpx;
				width: 300rpx;
				top: 560rpx;
			}

			.bttc {
				z-index: 20;
				position: absolute;
				top: 950rpx;
				left: 0;
				right: 0;

				.bcbutton {
					width: 650rpx;
					height: 100rpx;
					background: linear-gradient(90deg, #BB73D5, #643A92);
					box-shadow: 0px 4rpx 6rpx 0px rgba(100, 58, 146, 0.4);
					border-radius: 20rpx;

					text {
						width: 128rpx;
						height: 32rpx;
						font-size: 32rpx;
						font-family: Microsoft YaHei;
						font-weight: 400;
						color: #FFFFFF;
						line-height: 34rpx;
					}
				}
			}



		}




	}
</style>
